import { _decorator, Color, Component, Node, Sprite } from 'cc';
import { ResMgr } from '../Mgr/ResMgr';
import { GAMEDATA } from './GAMEDATA';
const { ccclass, property } = _decorator;

export type CardType = {
    num: number,
    color: number
}

@ccclass('BaseCard')
/**
 * 基础攻击卡牌
 */
export class BaseCard extends Component {

    //大数字
    @property(Sprite)
    public BigNum: Sprite = null;

    //小数字
    @property(Sprite)
    private SmallNum: Sprite = null;

    //花色
    @property(Sprite)
    private Color: Sprite = null;

    //卡牌信息
    public CardInfo: CardType = null;

    /**
     * 更新样式
     */
    public UpdateCard(_cardtype: CardType) {
        this.CardInfo = _cardtype;

        this.BigNum.spriteFrame = ResMgr.Instance.SpriteFrames["game_cardflower" + this.CardInfo.color.toString()];
        this.SmallNum.spriteFrame = ResMgr.Instance.SpriteFrames["card_num" + this.CardInfo.num.toString()];

        this.SmallNum.color = new Color(GAMEDATA.CARD_COLOR[this.CardInfo.color]);

        this.Color.spriteFrame = ResMgr.Instance.SpriteFrames["game_cardflower" + this.CardInfo.color.toString()];
    }

}


